#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
@author: xjx
@time: 2024/4/19 16:42 
@file: speed_analysis.py
@project: nanchangproject
@describe: 用于读取csv文件后进行速度计算
"""
import pandas as pd


class SpeedAnalysisModel(object):
    def __init__(self):
        pass

    @staticmethod
    def speed_analyze(file_path: str):
        df = pd.read_csv(file_path)
        mean_speed = df['车速（km/h）'].mean()  # 计算总体的均值
        mean_speed = round(mean_speed, 4)
        df = df[df['车速（km/h）'] != 0]
        mean_speed_no_stop = df['车速（km/h）'].mean()  # 计算去除怠速后的均值
        mean_speed_no_stop = round(mean_speed_no_stop, 4)
        return mean_speed, mean_speed_no_stop
